﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    鲜啵主页
</asp:Content>
<asp:Content ID="script_css" ContentPlaceHolderID="script_css" runat="server">
    <link href="../../Content/Site.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/bar.css" rel="stylesheet" type="text/css" />
    <link href="../../Content/default.css" rel="stylesheet" />
    <script src="../../Scripts/artDialog.js" type="text/javascript"></script>
    <script type="text/javascript">
        function addAttention(liveid, userid) {
            var request = createRequest();
            var url = "Attention/Add";
            try {
                request.open("POST", url, true);
                request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                request.onreadystatechange = function () {
                    if (request.readyState == 4) {
                        if (request.status == 200) {
                            // 成功后弹出提示框
                            art.dialog({
                                title: '添加关注',
                                content: '添加关注成功！', //点击<a href="User">此处</a>跳转到用户页查看关注。
                                width: 360,
                                fixed: true,
                                lock: true,
                                okValue: '关闭',
                                ok: function () {
                                }
                            });
                        }
                    }
                    return null;
                };
                request.send("liveid=" + liveid + "&userid=" + userid);
            }
            catch (e) { }
        }

        function createRequest() {
            var xmlHttp = null;
            try {
                // 首先尝试遗留对象
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e) {
                try {
                    // 现在尝试ie实现
                    this.xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch (E) {
                    xmlHttp = false;
                }
            }
            if (!xmlHttp && typeof XMLHttpRequest != "undefined") {
                // 因为我们必须使用基于mozilla的浏览器，所以现在创建一个本地请求对象
                xmlHttp = new XMLHttpRequest();
            }
            return xmlHttp;
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="loginHolder" runat="server">
    <%if (HttpContext.Current.Session["current_user"] != null)
      { %>
    <%Html.RenderPartial("UserStateControl", HttpContext.Current.Session["current_user"]); %>
    <%}
      else
      { %>
    <%=Html.ActionLink("注册", "Register", "User")%>
    <%=Html.ActionLink("登录", "Login", "User") %>
    <%} %>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="categories" runat="server">
    <strong>
        <%Html.RenderPartial("LiveCategoryControl", ViewData["categories"]); %>
    </strong>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <table width="99%">
        <%foreach (XianboSite.Models.Live item in (IList<XianboSite.Models.Live>)ViewData["live"])
          {%>
        <tr>
            <td style="width: 170px;">
                <%= Html.Label(item.CreateTime.ToString()) %>
            </td>
            <td style="width: 90px;">
                <%= Html.Label(item.CategoryName)%>
            </td>
            <td style="width: 400px;">
                <%= Html.ActionLink(item.LiveName, "Index", "LiveDetailsInfo", new { ID = item.LiveID }, new { style = "color:gold;text-decoration: none;font-weight:bold;font-size:14px;" })%>
            </td>
            <td align="right">
                <%=Html.ActionLink("评论", "Index", "Comment") %>
            </td>
            <% XianboSite.Models.User user = HttpContext.Current.Session["current_user"] as XianboSite.Models.User; %>
            <% if (user != null)
               { %>
            <td align="right">
                <a href="#" onclick="addAttention('<%=item.LiveID %>','<%=user.UserID%>');">关注</a>
            </td>
            <%}; %>
            <td align="right">
                <img src="../../Images/star.png" style="width: 20px; height: 20px;" />
                <img src="../../Images/star.png" style="width: 20px; height: 20px;" />
            </td>
        </tr>
        <%} %>
    </table>
    <table width="99%">
        <%foreach (XianboSite.Models.Live item in (IList<XianboSite.Models.Live>)ViewData["live"])
          {%>
        <tr>
            <td style="width: 170px;">
                <%= Html.Label(item.CreateTime.ToString()) %>
            </td>
            <td style="width: 90px;">
                <%= Html.Label(item.CategoryName)%>
            </td>
            <td style="width: 400px;">
                <%= Html.ActionLink(item.LiveName, "Index", "LiveDetailsInfo", new { ID = item.LiveID }, new { style = "color:#33CC00;text-decoration: none;font-size:14px;" })%>
            </td>
            <td align="right">
                <%=Html.ActionLink("评论", "Index", "Comment", new { liveid = item.LiveID }, null)%>
            </td>
            <% XianboSite.Models.User user = HttpContext.Current.Session["current_user"] as XianboSite.Models.User; %>
            <% if (user != null)
               { %>
            <td align="right">
                <a href="#" onclick="addAttention('<%=item.LiveID %>','<%=user.UserID%>');">关注</a>
            </td>
            <%}; %>
            <td align="right">
                <img alt="" src="../../Images/star.png" style="width: 20px; height: 20px; visibility: hidden;" />
                <img alt="" src="../../Images/star.png" style="width: 20px; height: 20px; visibility: hidden;" />
            </td>
        </tr>
        <%} %>
    </table>
</asp:Content>
